<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>

<ul class="breadcrumb panel">
    <li><a href="javascript:backMainFun();"><i class="fa fa-home"></i> 首页</a></li>
    <li class="active">修改密码</li>
</ul>


<div class="panel">
    <header class="panel-heading">
        修改密码
    </header>
    <div class="panel-body">
        <form action="${ctx}/xxx/xxx" name="pwdForm" id="pwdForm" method="post" class="form-horizontal">
            <div class="form-group">
                <label for="user_pwd" class="col-sm-2 control-label must">原密码</label>
                <div class="col-sm-8">
                    <input type="password" class="form-control" id="user_pwd" name="user_pwd" placeholder="请输入原密码">
                </div>
            </div>
            <div class="form-group">
                <label for="new_pwd" class="col-sm-2 control-label must">新密码</label>
                <div class="col-sm-8">
                    <input type="password" class="form-control" id="new_pwd" name="new_pwd" placeholder="请输入新密码">
                </div>
            </div>
            <div class="form-group">
                <label for="new_pwd2" class="col-sm-2 control-label must">确认密码</label>
                <div class="col-sm-8">
                    <input type="password" class="form-control" id="new_pwd2" name="new_pwd2" placeholder="确认密码">
                </div>
            </div>
            <div class="row">
                <div class="col-xs-10">
                    <button type="button" class="btn btn-primary pull-right" id="subBtn"><i class="glyphicon glyphicon-saved"></i> 保存</button>
                    <button type="button" class="btn btn-default pull-right marR" onclick="backFun()"><i class="glyphicon glyphicon-chevron-left"></i> 返回</button>
                </div>
            </div>

        </form>
    </div>
</div>


<script>

    $('#subBtn').click(function(){
        if($('#user_pwd').val()==false){
            zAlert('请输入原密码','修改失败');
        }else if($('#new_pwd').val()==false){
            zAlert('请输入新密码','修改失败');
        }else if($('#new_pwd2').val()!=$('#new_pwd').val()){
            zAlert('两次密码输入不一致','修改失败');
        }else{
            $.ajax({
                url:"${ctx}/user/updPwd",
                type:'post',
                data:{
                    user_pwd:$('#user_pwd').val(),
                    new_pwd:$('#new_pwd').val()
                },
                success:function(data){
                    if(data.success){
                        zAlert(data.msg);
                        setTimeout(function(){
                            location.href="${ctx}/account/index";
                    },1000);
                    }else{
                        zAlert(data.msg);
                    }
                }
            })
        }
    });


</script>






















